package demo;

public class test2 {
    //需求：字符串装换成数字,再转换成字符串
    public static void main(String[] args) {
        //1.创建字符串
        String str="123456";
        //2.遍历字符串，把字符转换成数字，再累加
        //2.1遍历字符串
        int sum=0;
        for (int i = 0; i < str.length(); i++) {
            char c=str.charAt(i);
            int t=c-48;
            sum=sum*10+t;
        }

        System.out.println(sum);
    }
}
